package org.cskt.sl.sys.service.impl;

import java.util.List;

import org.cskt.sl.sys.dao.PartMapper;
import org.cskt.sl.sys.entity.Part;
import org.cskt.sl.sys.example.PartExample;
import org.cskt.sl.sys.service.PartService;
import org.cskt.sl.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PartServiceImpl implements PartService {

	@Autowired
	private PartMapper partMapper; 
	
	@Override
	public int countByExample(PartExample example) {
		// TODO Auto-generated method stub
		return partMapper.countByExample(example);
	}

	@Override
	public int deletePartById(Integer pid) {
		// TODO Auto-generated method stub
		return partMapper.deleteByPrimaryKey(pid);
	}

	@Override
	public int addPart(Part record) {
		// TODO Auto-generated method stub
		return partMapper.insertSelective(record);
	}

	@Override
	public List<Part> findPartPageList(PartExample example, Pager pager) {
		// TODO Auto-generated method stub
		return partMapper.selectByExample(example, (pager.getCurrentPage()-1)*pager.getPageSize(), pager.getCurrentPage()*pager.getPageSize());
	}

	@Override
	public Part getPartById(Integer pid) {
		// TODO Auto-generated method stub
		return partMapper.selectByPrimaryKey(pid);
	}

	@Override
	public int updatePartById(Part record) {
		// TODO Auto-generated method stub
		return partMapper.updateByPrimaryKey(record);
	}

}
